package com.atguigu.gulimall.ware.dao;

import com.atguigu.gulimall.ware.entity.WareSkuEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 商品库存
 * 
 * @author kaiyi
 * @email corwienwong@gmail.com
 * @date 2020-08-11 01:45:30
 */
@Mapper
public interface WareSkuDao extends BaseMapper<WareSkuEntity> {

  void addStock(@Param("skuId") Long skuId, @Param("wareId") Long wareId, @Param("skuNum") Integer skuNum);

  Long getSkuStock(Long skuId);

  /**
   * 查询有库存的仓库
   *
   * @param skuId
   * @return
   */
  List<Long> listWareIdHasSkuStock(@Param("skuId") Long skuId);

  /**
   * 锁定库存
   * @param skuId
   * @param wareId
   * @param num
   * @return
   */
  Long lockSkuStock(@Param("skuId") Long skuId, @Param("wareId") Long wareId, @Param("num") Integer num);

  /**
   * 解锁库存
   * @param skuId
   * @param wareId
   * @param num
   */
  void unLockStock(@Param("skuId") Long skuId, @Param("wareId") Long wareId, @Param("num") Integer num);
}
